<?php
// remplissage du champ "score_SARA" dans diagnostic
$query_remplissage_score_SARA = "UPDATE `$db`.`diagnostic` SET `score_SARA` = '$score_SARA' WHERE `diagnostic`.`form` = " . $_SESSION ['form'];
mysql_query ( $query_remplissage_score_SARA ) or die ( "impossible de remplir le score SARA : " . mysql_error () );
// ~ mysqli_query($link,$query_remplissage_score_SARA) or die("impossible de remplir le score SARA : " . mysql_error());

// remplissage des valeurs dans la table SARA
if (isset ( $_POST ['gait'] )) {
	$gait = $_POST ['gait'];
} else {
	$gait = '';
}
if (isset ( $_POST ['stance'] )) {
	$stance = $_POST ['stance'];
} else {
	$stance = '';
}
if (isset ( $_POST ['sitting'] )) {
	$sitting = $_POST ['sitting'];
} else {
	$sitting = '';
}
if (isset ( $_POST ['speech'] )) {
	$speech = $_POST ['speech'];
} else {
	$speech = '';
}
if (isset ( $_POST ['fingerchaseright'] )) {
	$fingerchaseright = $_POST ['fingerchaseright'];
} else {
	$fingerchaseright = '';
}
if (isset ( $_POST ['fingerchaseleft'] )) {
	$fingerchaseleft = $_POST ['fingerchaseleft'];
} else {
	$fingerchaseleft = '';
}
if (isset ( $_POST ['scorefingerchase'] )) {
	$scorefingerchase = $_POST ['scorefingerchase'];
} else {
	$scorefingerchase = '';
}
if (isset ( $_POST ['nosefingerright'] )) {
	$nosefingerright = $_POST ['nosefingerright'];
} else {
	$nosefingerright = '';
}
if (isset ( $_POST ['nosefingerleft'] )) {
	$nosefingerleft = $_POST ['nosefingerleft'];
} else {
	$nosefingerleft = '';
}
if (isset ( $_POST ['scorenosefinger'] )) {
	$scorenosefinger = $_POST ['scorenosefinger'];
} else {
	$scorenosefinger = '';
}
if (isset ( $_POST ['handmovementsright'] )) {
	$handmovementsright = $_POST ['handmovementsright'];
} else {
	$handmovementsright = '';
}
if (isset ( $_POST ['handmovementsleft'] )) {
	$handmovementsleft = $_POST ['handmovementsleft'];
} else {
	$handmovementsleft = '';
}
if (isset ( $_POST ['scorehandmovements'] )) {
	$scorehandmovements = $_POST ['scorehandmovements'];
} else {
	$scorehandmovements = '';
}
if (isset ( $_POST ['heelshinright'] )) {
	$heelshinright = $_POST ['heelshinright'];
} else {
	$heelshinright = '';
}
if (isset ( $_POST ['heelshinleft'] )) {
	$heelshinleft = $_POST ['heelshinleft'];
} else {
	$heelshinleft = '';
}
if (isset ( $_POST ['scoreheelshin'] )) {
	$scoreheelshin = $_POST ['scoreheelshin'];
} else {
	$scoreheelshin = '';
}

$hash_SARA = array (
		"form" => $_SESSION ['form'],
		"gait" => $gait,
		"stance" => $stance,
		"sitting" => $sitting,
		"speech" => $speech,
		"fingerchaseright" => $fingerchaseright,
		"fingerchaseleft" => $fingerchaseleft,
		"scorefingerchase" => $scorefingerchase,
		"nosefingerright" => $nosefingerright,
		"nosefingerleft" => $nosefingerleft,
		"scorenosefinger" => $scorenosefinger,
		"scorenosefinger" => $scorenosefinger,
		"handmovementsright" => $handmovementsright,
		"handmovementsleft" => $handmovementsleft,
		"scorehandmovements" => $scorehandmovements,
		"heelshinright" => $heelshinright,
		"heelshinleft" => $heelshinleft,
		"scoreheelshin" => $scoreheelshin 
);

foreach ( $hash_SARA as $key => $value ) {
	if ($key != '') {
		$value = mysql_real_escape_string ( $value );
		// ~ $value = mysqli_real_escape_string($link,$value);
		$value = str_replace ( ',', '.', $value );
		$query_update_form = "UPDATE `" . $db . "`.`sara` SET `$key` = '$value' WHERE `sara`.`form` = " . $_SESSION ['form'];
		// echo $query_update_form;
		mysql_query ( $query_update_form ) or die ( "impossible d'updater la form : " . mysql_error () );
		// ~ mysqli_query($link,$query_update_form) or die("impossible d'updater la form : " . mysql_error());
	} else {
		$query_update_form = "UPDATE `" . $db . "`.`sara` SET `$key` = NULL WHERE `sara`.`form` = " . $_SESSION ['form'];
		mysql_query ( $query_update_form ) or die ( "impossible d'updater la form : " . mysql_error () );
		// ~ mysqli_query($query_update_form) or die("impossible d'updater la form : " . mysql_error());
	}
}

?>
